package com.ws.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ws.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface UserMapper extends BaseMapper<User> {

    @Select("<script>" +
            "select " +
            "u.id, " +
            "u.username, " +
            "u.role_id, " +
            "r.role_name,  " +
            "u.dept_id,  " +
            "d.`name` dept_Name,  " +
            "u.nickname,  " +
            "u.face,  " +
            "u.type,  " +
            "u.insert_time  " +
            "from   " +
            "shop_admin u   " +
            "join shop_role r on u.role_id = r.id  " +
            "join shop_dept d on u.dept_id = d.id  " +
            "where  " +
            "u.type = 0" +
            "<if test='username != \"\"'>" +
            "and u.username like '%${username}%'" +
            "</if>" +
            "</script>")
    Page<User> getAdminListForPage(Page<User> p, @Param("username") String username);
}
